package pingan.com.imandtwo.fragments.newsfragments.one;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import pingan.com.imandtwo.R;
import pingan.com.imandtwo.bean.Shouye;

/**
 * Created by 迷人的脚毛！！ on 2018/2/7.
 */

public class Recycler_Chuanxing extends RecyclerView.Adapter<Recycler_Chuanxing.ViewHolder> {


    private Context context;
    private List<Shouye.NewslistBean> list;

    public Recycler_Chuanxing(Context context, List<Shouye.NewslistBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View inflate = View.inflate(context, R.layout.one_chuanxing, null);
        ViewHolder viewHolder = new ViewHolder(inflate);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.name.setText(list.get(position).getTitle());
        holder.shijian.setText(list.get(position).getCtime());
        holder.mingzi.setText(list.get(position).getDescription());
        Uri uri = Uri.parse(list.get(position).getPicUrl());
        holder.img.setImageURI(uri);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{

        private TextView name;
        private TextView mingzi;
        private TextView shijian;
        private SimpleDraweeView img;

        public ViewHolder(View itemView) {
            super(itemView);
             name=(TextView) itemView.findViewById(R.id.chuanxing_name);
              mingzi=(TextView) itemView.findViewById(R.id.chuanxing_minzi);
              shijian=(TextView) itemView.findViewById(R.id.chuanxing_shijian);
             img=(SimpleDraweeView) itemView.findViewById(R.id.chuanxing_imgaaa);
        }
    }

}
